<?php

/**
 * @author liempv
 * @copyright 2012
 */


defined('DSVH') or die('Restricted access');

//add chuc danh
function insertHuongDan($local){
    mysql_query("insert huong_dan set 
    ten_huong_dan = '".$local['ten_huong_dan']."',
    alias = '".make_alias($local['ten_huong_dan'])."',
    loai = '".$local['loai']."',
    noi_dung = '".$local['noi_dung']."',
    nguoi_viet_id = '".$_SESSION['can_bo_id']."'
    ",dbconnect());
}
//list chuc danh
function getlisthuongdan($start,$limit)
    {
        $local_list = mysql_query("SELECT * FROM huong_dan
        left join loai_huong_dan ON huong_dan.loai = loai_huong_dan.loai_huong_dan_id
        left join can_bo ON huong_dan.nguoi_viet_id = can_bo.can_bo_id
        order by loai asc limit ".(int)$start.",".(int)$limit."
         ", dbconnect());
        $result = array();
        while ($local = mysql_fetch_array($local_list)){
            $result []= $local;
        }
        return $result;
    }
    
function getlistloaihuongdan()
    {
        $local_list = mysql_query("SELECT * FROM loai_huong_dan
       
        ", dbconnect());
        $result = array();
        while ($local = mysql_fetch_array($local_list)){
            $result []= $local;
        }
        return $result;
    }    
    
//ham lay du lieu phong ban theo id
function gethuongdan($id)
    {
    $pro = mysql_query("select * from huong_dan 
    left join loai_huong_dan ON huong_dan.loai = loai_huong_dan.loai_huong_dan_id
    where huong_dan_id = '".(int)$id."'", dbconnect());
    return mysql_fetch_array($pro);
    }
//cap nhat trong muc sua

function edithuongdan($id, $local)
{
    mysql_query("update huong_dan set ten_huong_dan ='".$local['ten_huong_dan']."',
    alias = '".make_alias($local['ten_huong_dan'])."',
    loai = '".$local['loai']."',
    ten_huong_dan = '".$local['ten_huong_dan']."',
    noi_dung = '".$local['noi_dung']."'
    where huong_dan_id = '".(int)$id."'", dbconnect());
}
// xoa thu muc
function delhuongdan($id){
    mysql_query("delete from huong_dan where huong_dan_id ='".(int)$id."'", dbconnect());
}


function totalhuongdan(){
   $result = mysql_query("select * from huong_dan",dbconnect());
    return mysql_num_rows($result);
}

?>